package com.aaa.fees.service.ipml;

import com.aaa.entity.Backfee;
import com.aaa.entity.BackfeeItem;
import com.aaa.fees.dao.BackfeesDao;
import com.aaa.fees.service.BackfeesService;
import com.aaa.fees.vo.BackfeeVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class BackfeesServiceImpl implements BackfeesService {
    @Autowired
    BackfeesDao backfeesDao;
    @Override
    public Result<List<Backfee>> getBackfeesInfo() {
        QueryWrapper<Backfee> wrapper = new QueryWrapper<>();
        List<Backfee> backfee= backfeesDao.selectList(wrapper);
        return new Result<>(200,"成功",backfee);
    }

    @Override
    public Result<IPage<Backfee>> getinfoBackfee(Integer currentPage, Integer pageSize, BackfeeVo backfeeVo) {
        IPage<Backfee> page=new Page<>(currentPage,pageSize);
        QueryWrapper<Backfee> wrapper=new QueryWrapper<>();
        if(StringUtils.hasText(backfeeVo.getPatientName())){
            wrapper.like("patient_name",backfeeVo.getPatientName());
        }
        if(StringUtils.hasText(backfeeVo.getRegId())){
            wrapper.like("reg_id",backfeeVo.getRegId());
        }
        IPage<Backfee> page1 = backfeesDao.selectPage(page, wrapper);
        return new Result<IPage<Backfee>>(200,"查询用户成功",page1);
    }
}
